package de.breitbeil.jbooking.ui.form;

import org.springframework.binding.form.FormModel;
import org.springframework.richclient.settings.Settings;

import de.breitbeil.jbooking.domain.Booking;
import de.breitbeil.jbooking.domain.Person;
import de.breitbeil.jbooking.ui.preferences.SettingsFormObject;

public class BookingTemplateFormObject implements SettingsFormObject {

    private String template;
    private String output;
    private boolean openOutput;
    private Person person;
    private Booking booking;
    
    public void setOutput(String output) {
        this.output = output;
    }
    public String getOutput() {
        return output;
    }
	public void setOpenOutput(boolean openOutput) {
		this.openOutput = openOutput;
	}
	public boolean isOpenOutput() {
		return openOutput;
	}
    public void setTemplate(String template) {
        this.template = template;
    }
    public String getTemplate() {
        return template;
    }
    public void setPerson(Person person) {
        this.person = person;
    }
    public Person getPerson() {
        return person;
    }
    public void setBooking(Booking booking) {
        this.booking = booking;
    }
    public Booking getBooking() {
        return booking;
    }
    
    public void fillDefaults(FormModel formModel) {
        formModel.getValueModel("template").setValue("");
        formModel.getValueModel("output").setValue("");
        formModel.getValueModel("openOutput").setValue(false);
    }

    public void init(Settings settings) {
        template = settings.getString("bookingTemplate.template");
        output = settings.getString("bookingTemplate.output");
        openOutput = settings.getBoolean("bookingTemplate.openOutput");
    }

    public void save(Settings settings) {
        settings.setString("bookingTemplate.template", template);
        settings.setString("bookingTemplate.output", output);
        settings.setBoolean("bookingTemplate.openOutput", openOutput);
    }

}
